<%@page import="com.surelution.tinyerp.FeeTypeCategory"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="layout" content="main"/>
<g:set var="entityName" value="${message(code: 'costList.label', default: 'costList')}" />
<g:javascript library="jquery"/>
<resource:dateChooser />
<link rel="stylesheet" href="${resource(dir:'css',file:'defaultTheme.css')}" />
<script type="text/javascript" src="${resource(dir:'js/jquery',file:'jquery.fixedheadertable.min.js')}"></script>
<script type="text/javascript" src="${resource(dir:'js/jquery',file:'jquery.printElement.min.js')}"></script>
<title><g:message code="default.costAnalysis.label" /></title>
	<script type="text/javascript">
		$(document).ready(function() {
		   $("#simplePrint").click(function() {
		       printElem({leaveOpen: true, printMode: 'popup', overrideElementCSS: ["${resource(dir:'plugins/richui-0.8/css',file:'calendarmonthview.css')}","${resource(dir:'css',file:'main.css')}"]});
		   });
		   $('#myTable01').fixedHeaderTable({ footer: false, cloneHeadToFoot: false, autoShow: true });
		});
		function printElem(options){
		    $('#monthReport').printElement(options);
		};
		
	</script>
	<script type="text/javascript" src="${resource(dir:'js/datechooser',file:'datechooser.js')}"></script>
</head>

<body>
  <div class="body">
          <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
            <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
          </div>
          <div>
            <p style="font-size:16px;color:#000;margin:10px 0;">合同成本占比</p>
        	<g:form action="report">
        		<label style="font-size:14px;color:#000;">选择计划下发时间：</label>
        		<richui:dateChooser name="startDay" locale="zh" format="yyyy-MM-dd" value="${startDay}" />
        		至
        		<richui:dateChooser name="endDay" locale="zh" format="yyyy-MM-dd" value="${endDay}" />
    			<span class="menuButton" style="margin-right:5px;"><g:actionSubmit value="${message(code: 'default.button.report.label', default: 'report')}" action="costAnalysis"/></span>
			    <span class="menuButton"><g:actionSubmit value="${message(code: 'default.button.export.label', default: 'Export')}" action="gasExport"/></span>
			    <input type="button" value="打印报表" id="simplePrint" />
			</g:form>
			<g:if test="${flash.message}">
            	<div class="message">${flash.message}</div>
            </g:if>
        </div>
        <%
			def feeSum=0
		 %>
        <div id="monthReport" style="height:650px;">
			<label style="font-size:16px;color:#000;">报表日期：  ${startDay?.format("yyyy年MM月")}到${endDay?.format("yyyy年MM月")} </label>
        		<table id="myTable01">
	        		<tr>
	        			<td style="text-align: center;vertical-align: middle;background:#75746a;color:#fff;">合同下发时间</td>
	        			<td style="text-align: center;vertical-align: middle;background:#75746a;color:#fff;">合同号</td>
	        			<td style="text-align: center;vertical-align: middle;background:#75746a;color:#fff;">直接材料费</td>
	        			<td style="text-align: center;vertical-align: middle;background:#75746a;color:#fff;">材料比</td>
	        			<td style="text-align: center;vertical-align: middle;background:#75746a;color:#fff;">人工成本</td>
	          			<td style="text-align: center;vertical-align: middle;background:#75746a;color:#fff;">人工比</td>
	        			<td style="text-align: center;vertical-align: middle;background:#75746a;color:#fff;">制造费用</td>
	          			<td style="text-align: center;vertical-align: middle;background:#75746a;color:#fff;">制造费用比</td>
	        			<td style="text-align: center;vertical-align: middle;background:#75746a;color:#fff;">外协加工费</td>
	          			<td style="text-align: center;vertical-align: middle;background:#75746a;color:#fff;">外协比</td>
	          			<td style="text-align: center;vertical-align: middle;background:#75746a;color:#fff;">合同成本总计</td>
	    			</tr>
	    		<tbody>
					<g:each in="${result}" var="r" status="i">
    				<tr>
	    				<td style="text-align:center;"><g:formatDate date="${r[0].assignTime}" format="yyyy年MM月dd日"/></td>
	    				<td style="text-align:center;"><g:link action="show" controller="purchaseOrder" params="${['id':r[0].id]}">${r[0].orderNo}</g:link></td>
	    				<td style="text-align:center;"><g:formatNumber number="${r[1]}" type="number" maxFractionDigits="2" /></td>
	    				<td style="text-align:center;"><g:formatNumber number="${r[5]}" type="number" maxFractionDigits="2" />%</td>
	    				<td style="text-align:center;"><g:formatNumber number="${r[2]}" type="number" maxFractionDigits="2" /></td>
	    				<td style="text-align:center;"><g:formatNumber number="${r[6]}" type="number" maxFractionDigits="2" />%</td>
	    				<td style="text-align:center;"><g:formatNumber number="${r[3]}" type="number" maxFractionDigits="2" /></td>
	    				<td style="text-align:center;"><g:formatNumber number="${r[7]}" type="number" maxFractionDigits="2" />%</td>
	    				<td style="text-align:center;"><g:formatNumber number="${r[4]}" type="number" maxFractionDigits="2" /></td>
	    				<td style="text-align:center;"><g:formatNumber number="${r[8]}" type="number" maxFractionDigits="2" />%</td>
	    				<td style="text-align:center;"><g:formatNumber number="${r[9]}" type="number" maxFractionDigits="2" /></td>
	    			</tr>
	    			</g:each>
    			</tbody>
          	</table>
        </div>
  </div>
</body>
</html>